import request from '@/utils/request'
import qs from 'qs'

// 获取所有菜品
export function getFoodList (pageNumber, pageSize,data) {
  return request({
    url: 'food/list_rewrite',
    method: 'get',
    params: {
      pageNumber,
      pageSize,
      foodName:data.foodName,
      foodType:data.foodType,
      isUse:data.isUse
    }
  })
}

// 添加菜品
export function addFood (data) {
  return request({
    url: '/food/save_rewrite',
    method: 'post',
    data: qs.stringify(
      data
    )
  })
}

// 删除菜品
export function deleteFoods (ids) {
  return request({
    url: '/food/delete',
    method: 'post',
    data: qs.stringify({
      ids
    }, {indices: false})
  })
}

// 编辑菜品
export function updateFood (foodInfo) {
  return request({
    url: '/food/update_rewrite',
    method: 'post',
    data: qs.stringify(
      foodInfo
    )
  })
}

//批量上下架
export function changeIsUse(isUse,ids) {
  return request({
    url: '/food/change_is_use',
    method: 'post',
    data: qs.stringify({
      isUse,
      ids
    }, {indices: false})
  })
}


//获取规格列表
export function getSpecList(foodId){
  return request({
    url:'standard_lev_one/list_rewrite',
    method:'get',
    params:{
      foodId:foodId,
    }
  })
}

//修改每个二级规格的价格
export function editPrice(standardTwoInfo){
  return request({
    url:'standard_lev_two/update_money',
    method:'post',
    data:qs.stringify({
      standardTwoInfo:standardTwoInfo
    })
  })
}



//添加一级规格
export function addOneSpec(foodId,flag,name){
  return request({
    url:'standard_lev_one/save_rewrite',
    method:'post',
    data:qs.stringify({
      foodId:foodId,
      flag:flag,
      name:name
    })
  })
}

//修改一级规格名称
export function updateLevOne(id,name,flag){
  return request({
    url:'standard_lev_one/update',
    method:'post',
    data:qs.stringify({
      id:id,
      name:name,
      flag:flag
    })
  })
}

//删除一级规格
export function removeLevOne(id){
  return request({
    url:'standard_lev_one/delete',
    method:'post',
    data:qs.stringify({
      ids:id,
    })
  })
}

//添加二级规格
export function addTwoSpec(id,name){
  return request({
    url:'standard_lev_two/save',
    method:'post',
    data:qs.stringify({
      standardLevOneId :id,
      name:name
    })
  })
}


//修改二级级规格名称
export function updateLevTwo(id,name){
  return request({
    url:'standard_lev_two/update',
    method:'post',
    data:qs.stringify({
      id :id,
      name:name
    })
  })
}

//删除二级规格
export function removeLevTwo(id){
  return request({
    url:'standard_lev_two/delete',
    method:'post',
    data:qs.stringify({
      ids:id,
    })
  })
}
